package cheme.ProcessEditor.Parts.ConsoleView;

import java.beans.PropertyChangeEvent;
import java.util.List;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Layer;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.gef.EditPolicy;

import cheme.ProcessEditor.Policies.ContentsModelPolicy;
import cheme.ProcessEditor.Policies.ProcessModelLayoutPolicy;
import cheme.ProcessModel.ContentsModel;
import cheme.ProcessModel.SimpleLogger;

public class ContentsEditPart extends EditPartWithListener
{
	private static String me = "cheme.ProcessEditor.Parts.ConsoleView.ContentsEditPart";
	XYLayout xYLayout;
	
	protected IFigure createFigure()
	{
		SimpleLogger.log(me, me + ".createFigure()");
		
		Layer figure = new Layer();
		figure.setLayoutManager(new XYLayout());
		return figure;
	}
	
	protected void createEditPolicies()
	{
		SimpleLogger.log(me, me + ".createEditPolicies()");
		
		installEditPolicy(EditPolicy.LAYOUT_ROLE, new ContentsModelPolicy());
	}
	
	protected List getModelChildren()
	{
		SimpleLogger.log(me, me + ".getModelChildren()");
		
		return ((ContentsModel) getModel()).getChildren();
	}
	
	public void propertyChange(PropertyChangeEvent evt)
	{
		SimpleLogger.log(me, me + ".propertyChange(evt)");
		
		if (evt.getPropertyName().equals(ContentsModel.P_CHILDREN))
		{
			refreshChildren();
		}
	}


}